/*
 * MatchingResource.h
 *
 *  Created on: 2013. 9. 10.
 *      Author: mega@gamevil.com
 */

#ifndef MATCHINGRESOURCE_H_
#define MATCHINGRESOURCE_H_

#include <map>

namespace ProjectZ { namespace NResource {

class MatchingData
{
public:
	struct Flyweight
	{
		int _TYPE;	// 0:최상급, 1:상급, 2:동급, 3:하급
		int _MIN_LEVEL;
		int _MAX_LEVEL;
		int _RATE;
	};

public:
	MatchingData() {}
	virtual ~MatchingData();

	bool LoadResource(int company, int saleCode);
	Flyweight * GetFly(int type);

private:
	void	Clear();

private:
	typedef std::map<int, Flyweight *>	DATATREE;
	DATATREE	clsFlyTree;
};


class MatchingResource
{
public:
	MatchingResource();
	virtual ~MatchingResource();

	bool LoadResource();
	MatchingData::Flyweight * GetFly(int company, int saleCode, int type);

	bool IsLowGrade(User * pUser, User * pOppUser)  { return CheckLevel(pUser, pOppUser, 3); }
	bool IsSameGrade(User * pUser, User * pOppUser) { return CheckLevel(pUser, pOppUser, 2); }
	bool IsHighGrade(User * pUser, User * pOppUser) { return CheckLevel(pUser, pOppUser, 1); }
	bool IsBestGrade(User * pUser, User * pOppUser) { return CheckLevel(pUser, pOppUser, 0); }

private:
	bool CheckLevel(User * pUser, User * pOppUser, int gradeType);

private:
	MatchingData * pMatchingAD;
	MatchingData * pMatchingIOS;
};

} /* NResource */ } /* ProjectZ */

#endif /* MATCHINGRESOURCE_H_ */
